/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package DAO;


import DataBase.AdminDB;
import DataBase.Transaccion;
import DataBase.TransacionException;
import java.sql.Connection;
import java.sql.PreparedStatement;

import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;

/**
 *
 * @author kossel
 */
public abstract class AbstractDAO <T> {
        public Transaccion transaccion = null;
        public AdminDB adminConsulta = AdminDB.obtenerInstancia();
        public List<Object> elements;
        public PreparedStatement pstmt;

        protected void initTransaccion(Connection conn) throws SQLException{
            transaccion = new Transaccion(conn);
            elements = new ArrayList<Object>();
        }

        protected void endTransaccion() throws SQLException{
          //posible llamar un metodo de cerrar conexion con seguro
        }


        
        public abstract void insertar(T objecto)throws TransacionException;
        public abstract void borrar(String condicion)throws TransacionException;
        public abstract void actualizar (T entidad, String condicion) throws TransacionException;
        public abstract List<T> buscar(String condicion,List<Object> params);


        public List<T> getAll(){
        return buscar("", null);
        }

        protected static void log(String str){
            System.out.println();
        }



}
